//package com.xxyy.mylive.ui;
//
//import android.content.pm.ActivityInfo;
//import android.content.res.Configuration;
//import android.os.Bundle;
//import android.view.KeyEvent;
//import android.view.WindowManager;
//
//import com.pili.pldroid.player.PLMediaPlayer;
//import com.xxyy.mylive.tools.UiTool;
//import com.xxyy.mylive.ui.manager.VideoPlayManager;
//
///**
// * Created by ado on 3:41 2016/10/22.
// */
//public abstract class BaseVideoActivity extends BaseActivity implements PLMediaPlayer.OnPreparedListener
//        , PLMediaPlayer.OnInfoListener, PLMediaPlayer.OnCompletionListener, PLMediaPlayer.OnErrorListener {
//    private VideoPlayManager mVideoPlayManager;
//    //播放地址
//    protected String mPlayURL = "";
//
//    @Override
//    protected void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        //屏幕常亮
//        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//    }
//
//    @Override
//    public void onPrepared(PLMediaPlayer plMediaPlayer) {
//
//    }
//
//    @Override
//    public boolean onInfo(PLMediaPlayer plMediaPlayer, int i, int i1) {
//        return false;
//    }
//
//    @Override
//    public void onCompletion(PLMediaPlayer plMediaPlayer) {
//        // TODO: 2016/10/21 这里先请求服务器主播直播是否结束。如果没有结束，开始重连。如果结束，关闭播放器。
//        if (null != mVideoPlayManager) mVideoPlayManager.stopPlay();
//    }
//
//    @Override
//    public boolean onError(PLMediaPlayer plMediaPlayer, int i) {
//        boolean isHandle = false;
//        switch (i) {
//            case -5:
//                UiTool.showToast(this, "网络异常，重新连接中·········");
//                break;
//            case -11:
//                UiTool.showToast(this, "与服务器断开，重新连接中·········");
//                mVideoPlayManager.setPlayUrl(mPlayURL);
//                mVideoPlayManager.startPlay();
//                isHandle = true;
//                break;
//            case -541478725:
//                UiTool.showToast(this, "播放列表为空");
//                break;
//            case -875574520:
//                UiTool.showToast(this, "直播不存在，断开连接");
//                mVideoPlayManager.stopPlay();
//                isHandle = false;
//                break;
//        }
//        return isHandle;
//    }
//
//    @Override
//    public boolean onKeyDown(int keyCode, KeyEvent event) {
//        if (keyCode == KeyEvent.KEYCODE_BACK) {
//            if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
//                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
//                return true;
//            }
//        }
//        return super.onKeyDown(keyCode, event);
//    }
//}
